from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome("C:\Program Files\driver\chromedriver.exe")
driver.maximize_window()

# 打开企业微信首页
driver.get("https://work.weixin.qq.com/")

# 点击-企业登录
driver.find_element(By.XPATH, "//a[text()='企业登录']").click()
# https://work.weixin.qq.com/wework_admin/frame

# 等待用户扫码登录
# time.sleep(20)

# # 获取所有cookies
# print(driver.get_cookies())
my_cookies = [
    {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.logined', 'path': '/', 'secure': False, 'value': 'true'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wwrtx.cs_ind', 'path': '/', 'secure': False, 'value': ''},
    {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wxpay.vid', 'path': '/', 'secure': False, 'value': '1688858211371146'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wxpay.corpid', 'path': '/', 'secure': False, 'value': '1970325261984975'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wwrtx.vid', 'path': '/', 'secure': False, 'value': '1688858211371146'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.ref', 'path': '/', 'secure': False, 'value': 'direct'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.ltype', 'path': '/', 'secure': False, 'value': '1'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': False, 'name': 'wwrtx.d2st', 'path': '/', 'secure': False, 'value': 'a6934285'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.refid', 'path': '/', 'secure': False, 'value': '36342331481202526'},
    {'domain': '.work.weixin.qq.com', 'expiry': 1665930015, 'httpOnly': False, 'name': 'wwrtx.i18n_lan', 'path': '/', 'secure': False, 'value': 'zh'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.vst', 'path': '/', 'secure': False, 'value': 'OJf312kRxmlSLQgm-V_nvqBbQKydDBB9_D2igD6CZLjTDjnlSEyZu3P25DuanPGk0RsMhRU_lMkVXL8iwUsZ3c4t7f21pM5LTp01FTuNO97dC10wEmpqI2AtlMWrKhI2I0VpJg0HtDlE0QkSZo_G7ipp1iwml122HQ9vzXkZ1aRBE9_0R9X8IR7_CszkWbxzIcLzjulH34Z4UWnwsjAg4jHNCLy8XTsfMrVtIMSeSgF5N362lX3aSZdcgt6SVGI_bnlIItHna5CKa5EOWiFOYg'},
    {'domain': '.work.weixin.qq.com', 'httpOnly': True, 'name': 'wwrtx.sid', 'path': '/', 'secure': False, 'value': 'lanyrmqDIWwVSFavtSOE4X-6rnzk4MzZfKnwgWMKT-SszQj5QiIrunr33oZ1a_lh'},
    {'domain': '.work.weixin.qq.com', 'expiry': 1694874001, 'httpOnly': False, 'name': 'wwrtx.c_gdpr', 'path': '/', 'secure': False, 'value': '0'}]

# 添加cookie
for cookie in my_cookies:
    driver.add_cookie(cookie)

driver.get("https://work.weixin.qq.com/wework_admin/frame")

time.sleep(5)


driver.quit()